CFLAGS = -g -O2 -Wall 
LDFLAGS = 
LIBS = 
ZLIB_LIBS =  -lz
ERLANG_LIBS = -L/usr/local/lib/erlang/lib/erl_interface-3.6.4/lib -lerl_interface -lei
ZLIB_CFLAGS = 
ERLANG_CFLAGS= -I/usr/local/lib/erlang/lib/erl_interface-3.6.4/include -I/usr/local/lib/erlang/usr/include
DYNAMIC_LIB_CFLAGS = -fpic -shared

all: ejabberd_zlib_drv.so test.beam ejabberd_zlib.beam

clean:
	rm -rfv *.beam
	rm -rfv *.so
	rm -rfv *~

test.beam: test.erl
	erlc -o $@ $<

ejabberd_zlib.beam: ejabberd_zlib.erl
	erlc -o $@ $<

ejabberd_zlib_drv.so:	%.so:	%.c
	gcc $(CFLAGS) $(LDFLAGS) $(LIBS) \
		$(subst ../,,$(subst .so,.c,$@)) \
		$(ZLIB_LIBS) \
		$(ZLIB_CFLAGS) \
		$(ERLANG_LIBS) \
		$(ERLANG_CFLAGS) \
		-o $@ \
		$(DYNAMIC_LIB_CFLAGS)
